package com.api.shopapi.mapper;

import com.api.shopapi.entity.CartGoodsPrice;
import com.api.shopapi.entity.dto.CartGoodsPriceDTO;
import com.api.shopapi.entity.dto.GoodsPriceDTO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface CartGoodsPriceMapper {


    @Insert("insert into cart_goods_price " +
            "(" +
            "CartGoodsPriceCode, " +
            "CartGoodsCode, " +
            "GoodsSizeCode, " +
            "GoodsColorCode, " +
            "Price" +
            ") " +
            "VALUES " +
            "(#{cartGoodsPrice.CartGoodsPriceCode} ," +
            "#{cartGoodsPrice.CartGoodsCode} ," +
            "#{cartGoodsPrice.GoodsSizeCode} ," +
            "#{cartGoodsPrice.GoodsColorCode} ," +
            "#{cartGoodsPrice.Price} " +
            ") ")
    int insert(@Param("cartGoodsPrice") CartGoodsPrice cartGoodsPrice);

    @Delete("delete from cart_goods_price where cartGoodsPriceCode=#{cartGoodsPriceCode}")
    int delete(@Param("cartGoodsPriceCode") String cartGoodsPriceCode);



    @Update("update cart_goods_price " +
            "set " +
            "CartGoodsCode=#{cartGoodsPrice.CartGoodsCode}," +
            "GoodsSizeCode=#{cartGoodsPrice.GoodsSizeCode}," +
            "GoodsColorCode=#{cartGoodsPrice.GoodsColorCode} , " +
            "Price=#{cartGoodsPrice.Price} " +
            "where " +
            "CartGoodsPriceCode=#{cartGoodsPrice.CartGoodsPriceCode}    ")
    int update(@Param("cartGoodsPrice") CartGoodsPrice cartGoodsPrice);

    @Select("select  * from cart_goods_price")
    List<CartGoodsPriceDTO> getList();

    @Select("select  * from cart_goods_price where CartGoodsPriceCode=#{cartGoodsPriceCode} limit 1")
    CartGoodsPriceDTO getByCartGoodsPriceCode(@Param("cartGoodsPriceCode") String cartGoodsPriceCode);

    @Select("select  * from cart_goods_price where cartGoodsCode=#{cartGoodsCode} limit 1")
    CartGoodsPriceDTO getByCartGoodsCode(@Param("cartGoodsCode") String cartGoodsCode);



}
